package com.senseuni.da.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import com.senseuni.da.db.entity.MediaEntity

@Dao
interface MediaDao {

    @Insert
    fun insert(entity: MediaEntity) : Long

    @Insert
    fun insert(entities: List<MediaEntity>)

    @Query("SELECT * FROM app_media WHERE uuid = :uuid LIMIT 1")
    fun findByUUID(uuid: String): MediaEntity?

    @Query("SELECT * from app_media where hide = 0 order by id desc")
    fun findAll() : List<MediaEntity>?

    @Query("UPDATE app_media set hide = 1 where id =:id")
    fun updateHide(id: Long)

    @Query("DELETE FROM app_media WHERE uuid = :uuid")
    fun deleteByUUID(uuid: String) : Int

    @Query("UPDATE app_media set hide = 0")
    fun reset()

    @Query("SELECT COUNT(*) FROM app_media  where hide = 0")
    fun count() : Int

    @Query("DELETE FROM app_media")
    fun deleteAll()

}